@extends('layouts.admin')
@section('css')
  <link href="{{ asset('admin/assets/advanced-datatable/media/css/demo_page.css') }}" rel="stylesheet" />
  <link href="{{ asset('admin/assets/advanced-datatable/media/css/demo_table.css') }}" rel="stylesheet">
@endsection
@section('content')
<section id="main-content">
          <section class="wrapper">
              <!-- page start-->
              <div class="row">
                  <div class="col-sm-12">
                      <section class="panel">
                          
                          <div class="panel-body">
                               <a href="{{ route('admin.wechat.reply') }}" type="button" class="btn btn-info ">文字回复</a>
                              <a href="{{ route('admin.wechat.reply.news') }}" type="button" class="btn btn-primary ">图文回复</a>                    
                          </div>
                      </section>
                  </div>
                  <div class="col-lg-12">
                      <section class="panel">
                        <div class="panel-body">
                            <div class="btn-group mr10 pull-right">
                                <a href="{{ route('admin.wechat.reply.create-news') }}" class="btn btn-white tooltips"
                                   data-toggle="tooltip" data-original-title="新增"><i
                                            class="glyphicon glyphicon-plus"></i></a>
                                <a class="btn btn-white tooltips deleteall" data-toggle="tooltip"
                                   data-original-title="删除" data-href="{{ route('admin.wechat.reply.destroy.all') }}"><i
                                            class="glyphicon glyphicon-trash"></i></a>
                            
                        </div><!-- pull-right -->
                       
                          <header class="panel-heading">
                              图文回复
                          </header>
                          <div class="panel-body">
                                <div class="adv-table">
                                    <table  class="display table table-bordered table-striped" id="reply">
                                      <thead>
                                      <tr>
                                          <th>
                                            <span class="ckbox ckbox-primary">
                                                <input type="checkbox" id="selectall"/>
                                                <label for="selectall"></label>
                                            </span>
                                        </th>
                                          <th>规则名称</th>
                                          <th>关键字</th>
                                          <th>正则</th>
                                          <th class="">标题</th>
                                          <th class="">描述</th>
                                          <th class="">图片</th>
                                          <th class="hidden-phone">操作</th>
                                      </tr>
                                      </thead>
                                      <tbody>
                                      @foreach($replies as $reply)
                                      <tr class="gradeX">
                                          <td>
                                              <div class="ckbox ckbox-default">
                                                  <input type="checkbox" name="id" id="id-{{ $reply->id }}"
                                                         value="{{ $reply->id }}" class="selectall-item"/>
                                                  <label for="id-{{ $reply->id }}"></label>
                                              </div>
                                          </td>
                                          <td>{{ $reply->name }}</td>
                                          <td>{{ $reply->keyword }}</td>
                                          <td>{{ $reply->regular }}</td>
                                          <td class="">{{ $reply->title }}</td>
                                          <td class="">{{ $reply->description }}</td>
                                          <td class="thumb p-thumb" ><img src="{{ asset($reply->picurl) }}" alt="" /></td>
                                          <td class="center hidden-phone">
                                               <a href="{{ route('admin.wechat.reply.edit',['id'=>$reply->id]) }}"
                                               class="btn btn-white btn-xs"><i class="icon-pencil"></i> 编辑</a>
                                            <a class="btn btn-danger btn-xs user-delete"
                                               data-href="{{ route('admin.wechat.reply.destroy',['id'=>$reply->id]) }}">
                                                <i class="icon-trash"></i> 删除</a>
                                          </td>
                                      </tr>
                                      @endforeach
                                      
                                      
                                      <tfoot>
                                      
                                      </tfoot>
                          </table>
                                </div>
                          </div>
                          </div>
                      </section>
                  </div>
              </div>
              <!-- page end-->
          </section>
      </section>
@endsection
@section('javascript')
<script type="text/javascript" language="javascript" src="{{ asset('admin/assets/advanced-datatable/media/js/jquery.dataTables.js') }}"></script>
 <script type="text/javascript" charset="utf-8">
      $(document).ready(function() {
          $('#reply').dataTable( {
              "aaSorting": [[ 4, "desc" ]],
              "oLanguage": {
                   "oPaginate": {
                     "sLast": "最后一页",
                     "sNext":"下页",
                     "sPrevious":"上页",
                     "sEmptyTable":"表里没有数据",
                   },
                   "sInfo": " _START_ - _END_ / _TOTAL_ 条记录",
                   "sLengthMenu": "显示 _MENU_ 条记录",
                   "sSearch": "搜索:",
                 }
          } );
      } );


        $(".user-delete").click(function () {
            Rbac.ajax.delete({
                'type':'get',
                confirmTitle: '确定删除自动回复?',
                href: $(this).data('href'),
                successTitle: '回复删除成功'
            });
        });

        $(".deleteall").click(function () {
            Rbac.ajax.deleteAll({
                'type':'post',
                confirmTitle: '确定删除选中的回复?',
                href: $(this).data('href'),
                successTitle: '回复删除成功'
            });
        });
    
      
  </script>  
@endsection

